import os
import logging
from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent
log_path = os.path.join(BASE_DIR, "logs")
if not os.path.exists(log_path):
    os.makedirs("logs")
from spider.detection import Detection


def run(site_all: list):
    # site_all = site_all[:1]
    for site in site_all:
        Detection(site).start()


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    site_all = [
        {"name": "河北亚大汽车经营管理系统",
         "config": {
             "home": {
                 "url": "https://oms.chinaust.com/"
             },
             "login": {
                 "url": "https://oms.chinaust.com/EHRTF/background/login/loginCheck.do",
                 "data": {
                     "userName": "huayunces1",
                     "userPassword": "Huayunces1@",
                     "remember": True
                 },
                 "send_type": "post",
                 "content_type": "application/json;charset=UTF-8"
             },
             "need_cookie": False
         }
         },
        {"name": "亚大经营管理系统",
         "config": {
             "home": {
                 "url": "https://oms.chinaust.com:10809/oms/"
             },
             "location_login": {
                 "url": "https://oms.chinaust.com:10809/oms/a"
             },
             "login": {
                 "url": "https://oms.chinaust.com:10809/oms/a/login",
                 "data": {"username": "huayunces1", "password": "111111"},
                 "send_type": "post",
                 "content_type": "application/x-www-form-urlencoded"
             },
             "need_cookie": True
         }
         },
        {"name": "云制MES",
         "config": {
             "home": {
                 "url": "http://www.freemes.cn/"
             },
             "need_cookie": False
         }
         },
        {"name": "云制MES-9002",
         "config": {
             "home": {
                 "url": "http://www.freemes.cn:9002/"
             },
             "login": {
                 "url": "http://121.36.159.185:9003/mgcloud/sys/login",
                 "data": {"username": "test", "password": "Test123.", "checkKey": "", "remember_me": True},
                 "send_type": "post",
                 "content_type": "application/json;charset=UTF-8"
             },
             "need_cookie": False
         }
         },
        {"name": "oms小程序",
         "config": {
             "login": {
                 "url": "https://oms.chinaust.com:10809/oms/a/login?username=huayunces2&password=111111&mobileLogin=true",
                 "data": {},
                 "send_type": "post",
                 "content_type": "application/json"
             },
             "need_cookie": False
         }
         },
        {"name": "app在前端web",
         "config": {
             "home": {
                 "url": "http://121.36.159.185:9006/#/pages/login/login"
             },
             "need_cookie": False
         }
         },
        {"name": "kkFileView演示首页",
         "config": {
             "home": {
                 "url": "http://www.freemes.cn:8012/index",
                 # "find_word": "接入说明"
             },
             "need_cookie": False
         }
         }
    ]
    run(site_all)
